{% extends 'rebs/layouts/base.html' %}

{% load static %}
{% load humanize %}

{% block title %}Rebs - 입출금 내역 조회{% endblock %}

{% block content %}

    <!-- Start Content-->
    <div class="container-fluid">

        <!-- start page title -->
        {% include 'rebs/partials/content_title.html' with  second_bs="본사 회계 관리" title="일별 자금 현황" %}
        <!-- end page title -->

        <div class="row">
            <form class="form-horizontal p-0 col-12" method="get">
                <div class="col-lg-12">
                    <div class="card">
                        <div class="card-body">

                            {% with menu_order='1' %}
                                {% include 'rebs_cash/partials/head_menu_cash.html' %}
                            {% endwith %}

                            <div class="row">
                                <div class="col-sm-12 col-md-6">
                                    <div class="form-group row mb-3">
                                        <label for="{{ form.deal_date.id_for_label }}"
                                               class="col-3 col-form-label text-center bg-info-lighten">기준일자</label>
                                        <div class="col-7 col-lg-5">
                                            <input type="text" name="confirm_date" data-provide="datepicker"
                                                   data-date-format="yyyy-mm-dd" data-date-autoclose="true"
                                                   data-toggle="input-mask" data-mask-format="0000-00-00"
                                                   placeholder="기준일자" class="form-control" required=""
                                                   id="id_confirm_date" value="{{ confirm_date }}" maxlength="10">
                                        </div>
                                        <div class="col-2 col-lg-4">
                                            <input type="button" class="btn btn-info" value="검색" onclick="submit()">
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </form>

            <div class="col-lg-12">
                <div class="card">
                    <div class="card-body">
                        <div class="row">
                            <div class="col-md-6 col-lg-4 mb-3">
                                <ul class="nav nav-pills bg-nav-pills nav-justified mb-3">
                                    <li class="nav-item">
                                        <a href="#home-b2" data-toggle="tab" aria-expanded="false"
                                           class="nav-link active">
                                            <i class="mdi mdi-home-variant d-md-none d-block"></i>
                                            <span class="d-none d-md-block">계좌별 자금현황</span>
                                        </a>
                                    </li>
                                    <li class="nav-item">
                                        <a href="#profile-b2" data-toggle="tab" aria-expanded="true"
                                           class="nav-link">
                                            <i class="mdi mdi-account-circle d-md-none d-block"></i>
                                            <span class="d-none d-md-block">당일 입출현황</span>
                                        </a>
                                    </li>
                                    {#                                    <li class="nav-item">#}
                                    {#                                        <a href="#settings-b2" data-toggle="tab" aria-expanded="false" class="nav-link">#}
                                    {#                                            <i class="mdi mdi-settings-outline d-md-none d-block"></i>#}
                                    {#                                            <span class="d-none d-md-block">예산대비 현황</span>#}
                                    {#                                        </a>#}
                                    {#                                    </li>#}
                                </ul>
                            </div>
                            <br>

                            <div class="tab-content col-12">
                                <div class="tab-pane show active" id="home-b2">
                                    <div class="table-responsive">
                                        <table class="table table-hover table-centered table-condensed table-bordered table-sm w-100 m-0 nowrap">
                                            <thead>
                                            <tr>
                                                <th colspan="5"><span><i class="uil-layer-group text-info"></i></span>
                                                    본사 계좌별 자금현황 <small>({{ confirm_date }}) 현재</small>
                                                </th>
                                                <td class="text-right">(단위: 원)</td>
                                            </tr>
                                            <tr class="bg-dragula">
                                                <th class="text-center" colspan="2">구분</th>
                                                <th class="text-center">전일잔액</th>
                                                <th class="text-center">금일입금(증가)</th>
                                                <th class="text-center">금일출금(감소)</th>
                                                <th class="text-center">금일잔액</th>
                                            </tr>
                                            </thead>
                                            <tbody>
                                            {% for ba in bank_accounts %}
                                                <tr class="{% ifequal forloop.counter 1 %}bg-light-lighten{% endifequal %}">
                                                    {% if forloop.counter == 1 %}
                                                        <td class="text-center">
                                                            현금
                                                        </td>
                                                    {% endif %}
                                                    {% if forloop.counter == 2 %}
                                                        <td class="text-center" rowspan="{{ bank_accounts.count|add:"-1" }}">
                                                            보통예금
                                                        </td>
                                                    {% endif %}
                                                    <td>{{ ba }}</td>
                                                    <td class="text-right">{{ ba_1day_ago_total.pop|intcomma|default:"-" }}</td>
                                                    {# 전일 잔액 #}
                                                    <td class="text-right">{{ ba_to_inc.pop|intcomma|default:"-" }}</td>
                                                    {# 금일 입금 #}
                                                    <td class="text-right">{{ ba_to_out.pop|intcomma|default:"-" }}</td>
                                                    {# 금일 출금 #}
                                                    <td class="text-right">{{ ba_totay_balance.pop|intcomma|default:"-" }}</td>
                                                    {# 금일 잔액 #}
                                                </tr>
                                            {% endfor %}
                                            <tr class="bg-dragula">
                                                <th class="text-center" colspan="2">현금성 자산 계</th>
                                                <th class="text-right">{{ ba_1day_ago_total_sum|intcomma|default:"-" }}</th>
                                                <th class="text-right">{{ ba_to_inc_sum|intcomma|default:"-" }}</th>
                                                <th class="text-right">{{ ba_to_out_sum|intcomma|default:"-" }}</th>
                                                <th class="text-right">{{ ba_totay_balance_sum|intcomma|default:"-" }}</th>
                                            </tr>
                                            </tbody>
                                        </table>
                                    </div>
                                </div>
                                <div class="tab-pane" id="profile-b2">
                                    <div class="table-responsive">
                                        <table class="table table-hover table-centered table-condensed table-bordered table-sm w-100 m-0 nowrap">
                                            <thead>
                                            <tr>
                                                <th colspan="6"><span><i class="uil-layer-group text-info"></i></span>
                                                    프로젝트 당일 입금내역 <small>({{ confirm_date }}) 기준</small>
                                                </th>
                                                <td class="text-right">(단위: 원)</td>
                                            </tr>
                                            <tr class="bg-dragula">
                                                <th class="text-center">구분</th>
                                                <th class="text-center">계정</th>
                                                <th class="text-center">세부 계정</th>
                                                <th class="text-center">입금 금액</th>
                                                <th class="text-center">거래 계좌</th>
                                                <th class="text-center">거래처</th>
                                                <th class="text-center">적요</th>
                                            </tr>
                                            </thead>
                                            <tbody>

                                            {% for inc in day_inc_list %}
                                                <tr>
                                                    <td class="text-center">{{ inc.get_cash_category1_display }}</td>
                                                    <td class="text-center">{{ inc.get_cash_category2_display }}</td>
                                                    <td class="text-center">{{ inc.account|default:"-" }}</td>
                                                    <td class="text-right bg-success-lighten">{{ inc.income|intcomma|default:"-" }}</td>
                                                    <td class="text-center">{{ inc.bank_account }}</td>
                                                    <td>{{ inc.trader|default:"-" }}</td>
                                                    <td>{{ inc.content|default:"-" }}</td>
                                                </tr>
                                            {% endfor %}

                                            <tr>
                                                <td>&nbsp;</td>
                                                <td></td>
                                                <td></td>
                                                <td class="bg-success-lighten"></td>
                                                <td></td>
                                                <td></td>
                                                <td></td>
                                            </tr>

                                            <tr class="bg-dragula">
                                                <th class="text-center">합계</th>
                                                <th></th>
                                                <th></th>
                                                <th class="text-right">
                                                    {% ifequal day_inc_sum.income__sum None %}-{% else %}
                                                    {{ day_inc_sum.income__sum|intcomma|default:"-" }}{% endifequal %}
                                                </th>
                                                <th></th>
                                                <th></th>
                                                <th></th>
                                            </tr>
                                            </tbody>

                                            <tr>
                                                <td colspan="6">&nbsp;</td>
                                            </tr>

                                            <thead>
                                            <tr>
                                                <th colspan="6"><span><i class="uil-layer-group text-info"></i></span>
                                                    프로젝트 당일 출금내역 <small>({{ confirm_date }}) 기준</small>
                                                </th>
                                                <td class="text-right">(단위: 원)</td>
                                            </tr>
                                            <tr class="bg-dragula">
                                                <th class="text-center">구분</th>
                                                <th class="text-center">계정</th>
                                                <th class="text-center">세부 계정</th>
                                                <th class="text-center">출금 금액</th>
                                                <th class="text-center">거래 계좌</th>
                                                <th class="text-center">거래처</th>
                                                <th class="text-center">적요</th>
                                            </tr>
                                            </thead>
                                            <tbody>

                                            {% for out in day_out_list %}
                                                <tr>
                                                    <td class="text-center">{{ out.get_cash_category1_display }}</td>
                                                    <td class="text-center">{{ out.get_cash_category2_display }}</td>
                                                    <td class="text-center">{{ out.account|default:"-" }}</td>
                                                    <td class="text-right bg-info-lighten">{{ out.outlay|intcomma|default:"-" }}</td>
                                                    <td class="text-center">{{ out.bank_account }}</td>
                                                    <td>{{ out.trader|default:"-" }}</td>
                                                    <td>{{ out.content|default:"-" }}</td>
                                                </tr>
                                            {% endfor %}

                                            <tr>
                                                <td>&nbsp;</td>
                                                <td></td>
                                                <td></td>
                                                <td class="bg-info-lighten"></td>
                                                <td></td>
                                                <td></td>
                                                <td></td>
                                            </tr>

                                            <tr class="bg-dragula">
                                                <th class="text-center">합계</th>
                                                <th></th>
                                                <th></th>
                                                <th class="text-right">
                                                    {% ifequal day_out_sum.outlay__sum None %}-{% else %}
                                                    {{ day_out_sum.outlay__sum|intcomma|default:"-" }}{% endifequal %}
                                                </th>
                                                <th></th>
                                                <th></th>
                                                <th></th>
                                            </tr>
                                            </tbody>
                                        </table>
                                    </div>
                                </div>
                                <div class="tab-pane" id="settings-b2">
                                    <p>...</p>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

    </div> <!-- container -->

{% endblock %}
